#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e6+10;
const int mod = 1e9+7;

char s[MAXN];
int n,nxt[MAXN];
long long ans,sum[MAXN];

int main (){
	int T;scanf("%d",&T);
	while(T--){
		scanf("%s",s+1);
		n = strlen(s+1);
		nxt[1] = 0; sum[0] = 0;
		for(int i = 2,j = 0;i <= n;i++){
			while(j && s[j+1] != s[i]) j = nxt[j];
			if(s[j+1] == s[i]) j++;
			nxt[i] = j;
		}
		for(int i = 1;i <= n;i++) sum[i] = sum[nxt[i]]+1;
		ans = 1;
		for(int i = 2,j = 0;i <= n;i++){
			while(j && s[j+1] != s[i]) j = nxt[j];
			if(s[j + 1] == s[i]) j++;
			while(j<<1 > i) j = nxt[j];
			ans = ans * (sum[j]+1) % mod;
//			cout<<num[i]<<"..";
		}
		printf("%lld\n",ans);
	}
	return 0;
}
